home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / CWPWindow.cp < prev    next >
Text File  |  1997-06-28  |  3KB  |  128 lines

  1. // CWPWindow.cp
  2.  
  3. #ifndef CWPWindow_h
  4. #include "CWPWindow.h"
  5. #endif
  6. #ifndef CWPApplication_h
  7. #include "CWPApplication.h"
  8. #endif
  9. #ifndef ContextMaintainer_h
  10. #include "ContextMaintainer.h"
  11. #endif
  12. #ifndef WindowDefinition_h
  13. #include "WindowDefinition.h"
  14. #endif
  15. #ifndef Justification_h
  16. #include "Justification.h"
  17. #endif
  18. #ifndef OSError_h
  19. #include "OSError.h"
  20. #endif
  21.  
  22. CWPWindow *CWPApplication::NewCWPWindow( const WindowInitializer& initializer )
  23.   {
  24.     ContextMaintainer cm( 0 );
  25.     return new CWPWindow( initializer );
  26.   }
  27.  
  28. void UpdateProject();
  29.  
  30. CWPWindow::CWPWindow( const WindowInitializer& initializer )
  31.   : Window( WindowDefinition::Document() ),
  32.      remainingText( Face::System() ),
  33.      remainingNumber( Face::System() ),
  34.      compiling( Face::System() ),
  35.      bar( progress ),
  36.      progressFrame( 1 ),
  37.      margin( PointObject( 23, 13 ), NamedColors::white ),
  38.      space1( 10 ),
  39.      space2( 10 ),
  40.      ear( watcher, *this, &CWPWindow::UpdateProgress )
  41.   {
  42.     remainingText.SetString( "\pFiles remaining to be compiled: " );
  43.     remainingNumber.SetHorizontalJustification( Justification::Trailing() );
  44.     
  45.     remainingRow[0].SetView( remainingText );
  46.     remainingRow[1].SetView( remainingNumber );
  47.  
  48.     progressFrame.Interior().SetView( bar );
  49.     
  50.     column[0].SetView( remainingRow );
  51.     column[1].SetView( space1 );
  52.     column[2].SetView( compiling );
  53.     column[3].SetView( space2 );
  54.     column[4].SetView( progressFrame );
  55.  
  56.     margin.Interior().SetView( column );
  57.     
  58.     RootPane().SetView( margin );
  59.     
  60.     UpdateProgress();
  61.     
  62.     Initialize( initializer );
  63.     
  64.     UpdateProject();
  65.   }
  66.  
  67. CWPWindow::~CWPWindow()
  68.   {
  69.   }
  70.  
  71. void CWPWindow::UpdateProgress()
  72.   {
  73.     remainingNumber.SetNumber( watcher.FilesLeft() );
  74.     
  75.     String255 lineNumber;
  76.     NumToString( watcher.FileLine(), lineNumber );
  77.     
  78.     if ( watcher.File().Length() == 0 )
  79.         compiling.Clear();
  80.      else
  81.       {
  82.         String255 compilingText( "\pCompiling “" );
  83.         compilingText += watcher.File();
  84.         compilingText += "\p”    line ";
  85.         compilingText += lineNumber;
  86.         
  87.         compiling.SetString( compilingText );
  88.       }
  89.  
  90.     progress.Set( watcher.CompiledLines(), watcher.TotalLines() );
  91.     
  92.     column.Update();
  93.   }
  94.  
  95. void UpdateProject()
  96.   {
  97.     OSType signature = 'CWIE';
  98.     
  99.     AEAddressDesc address;
  100.     OSError error = AECreateDesc( typeApplSignature,
  101.                                             &signature,
  102.                                             sizeof( signature ),
  103.                                             &address );
  104.     error.Debug();
  105.     error.Throw();
  106.     
  107.     AppleEvent event;
  108.     error = AECreateAppleEvent( 'MMPR',
  109.                                         'UpdP',
  110.                                         &address,
  111.                                         kAutoGenerateReturnID,
  112.                                         kAnyTransactionID,
  113.                                         &event );
  114.     error.Debug();
  115.     error.Throw();
  116.                                                    
  117.     AppleEvent reply;
  118.     error = AESend( &event,
  119.                         &reply,
  120.                         kAENoReply,
  121.                         kAENeverInteract,
  122.                         5 * 60 * 60,
  123.                         0,
  124.                         0 );
  125.     error.Debug();
  126.     error.Throw();
  127.   }
  128.